ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilWebDAVMountInstructions Class Reference

Class ilWebDAVMountInstructions. More...

+ Collaboration diagram for ilWebDAVMountInstructions:

Public Member Functions

 __construct ($a_user_agent='', $a_request_uri='', $a_http_host='', $a_script_name='', $a_client_id='')
 
 instructionsTplFileExists ()
 
 getInstructionsFromTplFile ()
 
 getCustomInstruction ()
 
 getDefaultInstruction ()
 
 getWebfolderTitle ()
 
 getDefaultUri ()
 
 getIEUri ()
 
 getKonquerorUri ()
 
 getNautilusUri ()
 
 setInstructionPlaceholders ($a_instruction_tpl)
 Gets Webfolder mount instructions for the specified webfolder. More...
 

Protected Member Functions

 setValuesFromUserAgent ($a_user_agent)
 

Protected Attributes

 $user_agent
 
 $request_uri
 
 $http_host
 
 $script_name
 
 $client_id
 
 $path_to_template
 
 $clientOSFlavor
 
 $clientOS
 
 $settings
 
 $lng
 
 $ref_id
 
 $obj_id
 
 $obj_title
 

Detailed Description

Class ilWebDAVMountInstructions.

This class creates the page and links for the WebDAV mount instruction page

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.ilWebDAVMountInstructions.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVMountInstructions::__construct (   $a_user_agent = '',
  $a_request_uri = '',
  $a_http_host = '',
  $a_script_name = '',
  $a_client_id = '' 
)

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

31 {
32 global $DIC;
33
34 $this->settings = new ilSetting('file_access');
35 $this->lng = $DIC->language();
36
37 $this->user_agent = $a_user_agent == '' ? strtolower($_SERVER['HTTP_USER_AGENT']) : $a_user_agent;
38 $this->request_uri = $a_request_uri == '' ? $_SERVER['REQUEST_URI'] : $a_request_uri;
39 $this->http_host = $a_http_host == '' ? $_SERVER['HTTP_HOST'] : $a_http_host;
40 $this->script_name = $a_http_host == '' ? $_SERVER['SCRIPT_NAME'] : $a_script_name;
41 $this->client_id = $a_http_host == '' ? CLIENT_ID : $a_client_id;
42 $this->path_to_template = 'Customizing/clients/' . $this->client_id . '/webdavtemplate.htm';
43
44 $this->ref_id = 0;
45 foreach (explode('/', $this->request_uri) as $uri_part) {
46 if (strpos($uri_part, 'ref_') !== false && $this->ref_id == 0) {
47 $this->ref_id = (int) explode('_', $uri_part)[1];
48 }
49 }
50 if ($this->ref_id == 0) {
51 throw new Exception('Bad Request: No ref id given!');
52 } else {
53 $this->obj_id = ilObject::_lookupObjectId($this->ref_id);
54 $this->obj_title = ilObject::_lookupTitle($this->obj_id);
55 }
56
57 $this->base_uri = $this->http_host . $this->script_name . '/' . $this->client_id . '/ref_' . $this->ref_id . '/';
58
59 $this->protocol_prefixes = array(
60 'default' => 'https://',
61 'konqueror' => 'webdavs://',
62 'nautilus' => 'davs://'
63 );
64
65 $this->setValuesFromUserAgent($this->user_agent);
66 }
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
ILIAS Setting Class.
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_SERVER, $DIC, ilObject\_lookupObjectId(), ilObject\_lookupTitle(), settings(), and setValuesFromUserAgent().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCustomInstruction()

ilWebDAVMountInstructions::getCustomInstruction ( )

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

114 {
115 return $this->settings->get('custom_webfolder_instructions');
116 }

References settings().

+ Here is the call graph for this function:

◆ getDefaultInstruction()

ilWebDAVMountInstructions::getDefaultInstruction ( )

Definition at line 118 of file class.ilWebDAVMountInstructions.php.

119 {
120 return $this->lng->txt('webfolder_instructions_text');
121 }

◆ getDefaultUri()

ilWebDAVMountInstructions::getDefaultUri ( )

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

129 {
130 return $this->protocol_prefixes['default'] . $this->base_uri;
131 }

Referenced by setInstructionPlaceholders().

+ Here is the caller graph for this function:

◆ getIEUri()

ilWebDAVMountInstructions::getIEUri ( )

Definition at line 133 of file class.ilWebDAVMountInstructions.php.

134 {
135 // Was in the old webdav the same like default uri and is now still the same
136 return $this->protocol_prefixes['default'] . $this->base_uri;
137 }

Referenced by setInstructionPlaceholders().

+ Here is the caller graph for this function:

◆ getInstructionsFromTplFile()

ilWebDAVMountInstructions::getInstructionsFromTplFile ( )

Definition at line 108 of file class.ilWebDAVMountInstructions.php.

109 {
110 return fread(fopen($this->path_to_template, "rb"), filesize($this->path_to_template));
111 }

◆ getKonquerorUri()

ilWebDAVMountInstructions::getKonquerorUri ( )

Definition at line 139 of file class.ilWebDAVMountInstructions.php.

140 {
141 return $this->protocol_prefixes['konqueror'] . $this->base_uri;
142 }

Referenced by setInstructionPlaceholders().

+ Here is the caller graph for this function:

◆ getNautilusUri()

ilWebDAVMountInstructions::getNautilusUri ( )

Definition at line 144 of file class.ilWebDAVMountInstructions.php.

145 {
146 return $this->protocol_prefixes['nautilus'] . $this->base_uri;
147 }

Referenced by setInstructionPlaceholders().

+ Here is the caller graph for this function:

◆ getWebfolderTitle()

ilWebDAVMountInstructions::getWebfolderTitle ( )

Definition at line 123 of file class.ilWebDAVMountInstructions.php.

References $obj_title.

◆ instructionsTplFileExists()

ilWebDAVMountInstructions::instructionsTplFileExists ( )

Definition at line 103 of file class.ilWebDAVMountInstructions.php.

104 {
105 return is_file($this->path_to_template);
106 }

◆ setInstructionPlaceholders()

ilWebDAVMountInstructions::setInstructionPlaceholders (   $a_instruction_tpl)

Gets Webfolder mount instructions for the specified webfolder.

The following placeholders are currently supported:

[WEBFOLDER_TITLE] - the title of the webfolder [WEBFOLDER_URI] - the URL for mounting the webfolder with standard compliant WebDAV clients [WEBFOLDER_URI_IE] - the URL for mounting the webfolder with Internet Explorer [WEBFOLDER_URI_KONQUEROR] - the URL for mounting the webfolder with Konqueror [WEBFOLDER_URI_NAUTILUS] - the URL for mounting the webfolder with Nautilus [IF_WINDOWS]...[/IF_WINDOWS] - conditional contents, with instructions for Windows [IF_MAC]...[/IF_MAC] - conditional contents, with instructions for Mac OS X [IF_LINUX]...[/IF_LINUX] - conditional contents, with instructions for Linux [ADMIN_MAIL] - the mailbox address of the system administrator

Parameters
unknown$a_instruction_tpl
Returns
mixed

Definition at line 168 of file class.ilWebDAVMountInstructions.php.

169 {
170 $a_instruction_tpl = str_replace("[WEBFOLDER_ID]", $this->ref_id, $a_instruction_tpl);
171 $a_instruction_tpl = str_replace("[WEBFOLDER_TITLE]", $this->obj_title, $a_instruction_tpl);
172 $a_instruction_tpl = str_replace("[WEBFOLDER_URI]", $this->getDefaultUri(), $a_instruction_tpl);
173 $a_instruction_tpl = str_replace("[WEBFOLDER_URI_IE]", $this->getIEUri(), $a_instruction_tpl);
174 $a_instruction_tpl = str_replace("[WEBFOLDER_URI_KONQUEROR]", $this->getKonquerorUri(), $a_instruction_tpl);
175 $a_instruction_tpl = str_replace("[WEBFOLDER_URI_NAUTILUS]", $this->getNautilusUri(), $a_instruction_tpl);
176 $a_instruction_tpl = str_replace("[ADMIN_MAIL]", $this->settings->get("admin_email"), $a_instruction_tpl);
177
178 if (strpos($this->user_agent, 'MSIE') !== false) {
179 $a_instruction_tpl = preg_replace('/\[IF_IEXPLORE\](?:(.*))\[\/IF_IEXPLORE\]/s', '\1', $a_instruction_tpl);
180 } else {
181 $a_instruction_tpl = preg_replace('/\[IF_NOTIEXPLORE\](?:(.*))\[\/IF_NOTIEXPLORE\]/s', '\1', $a_instruction_tpl);
182 }
183
184 switch ($this->clientOS) {
185 case 'windows':
186 $operatingSystem = 'WINDOWS';
187 break;
188 case 'unix':
189 switch ($this->clientOSFlavor) {
190 case 'osx':
191 $operatingSystem = 'MAC';
192 break;
193 case 'linux':
194 $operatingSystem = 'LINUX';
195 break;
196 default:
197 $operatingSystem = 'LINUX';
198 break;
199 }
200 break;
201 default:
202 $operatingSystem = 'UNKNOWN';
203 break;
204 }
205 if ($operatingSystem != 'UNKNOWN') {
206 $a_instruction_tpl = preg_replace('/\[IF_' . $operatingSystem . '\](?:(.*))\[\/IF_' . $operatingSystem . '\]/s', '\1', $a_instruction_tpl);
207 $a_instruction_tpl = preg_replace('/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s', '', $a_instruction_tpl);
208 } else {
209 $a_instruction_tpl = preg_replace('/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s', '\2', $a_instruction_tpl);
210 }
211
212 return $a_instruction_tpl;
213 }

References getDefaultUri(), getIEUri(), getKonquerorUri(), getNautilusUri(), and settings().

+ Here is the call graph for this function:

◆ setValuesFromUserAgent()

ilWebDAVMountInstructions::setValuesFromUserAgent (   $a_user_agent)
protected

Definition at line 68 of file class.ilWebDAVMountInstructions.php.

69 {
70 // Guess operating system, operating system flavor and browser of the webdav client
71 //
72 // - We need to know the operating system in order to properly
73 // hide hidden resources in directory listings.
74 //
75 // - We need the operating system flavor and the browser to
76 // properly support mounting of a webdav folder.
77 //
78 if (strpos($a_user_agent, 'windows') !== false
79 || strpos($a_user_agent, 'microsoft') !== false) {
80 $this->clientOS = 'windows';
81 if (strpos($a_user_agent, 'nt 5.1') !== false) {
82 $this->clientOSFlavor = 'xp';
83 } else {
84 $this->clientOSFlavor = 'nichtxp';
85 }
86 } elseif (strpos($this->user_agent, 'darwin') !== false
87 || strpos($a_user_agent, 'macintosh') !== false
88 || strpos($a_user_agent, 'linux') !== false
89 || strpos($a_user_agent, 'solaris') !== false
90 || strpos($a_user_agent, 'aix') !== false
91 || strpos($a_user_agent, 'unix') !== false
92 || strpos($a_user_agent, 'gvfs') !== false // nautilus browser uses this ID
93 ) {
94 $this->clientOS = 'unix';
95 if (strpos($a_user_agent, 'linux') !== false) {
96 $this->clientOSFlavor = 'linux';
97 } elseif (strpos($a_user_agent, 'macintosh') !== false) {
98 $this->clientOSFlavor = 'osx';
99 }
100 }
101 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $client_id

ilWebDAVMountInstructions::$client_id
protected

Definition at line 17 of file class.ilWebDAVMountInstructions.php.

◆ $clientOS

ilWebDAVMountInstructions::$clientOS
protected

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

◆ $clientOSFlavor

ilWebDAVMountInstructions::$clientOSFlavor
protected

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

◆ $http_host

ilWebDAVMountInstructions::$http_host
protected

Definition at line 15 of file class.ilWebDAVMountInstructions.php.

◆ $lng

ilWebDAVMountInstructions::$lng
protected

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

◆ $obj_id

ilWebDAVMountInstructions::$obj_id
protected

Definition at line 27 of file class.ilWebDAVMountInstructions.php.

◆ $obj_title

ilWebDAVMountInstructions::$obj_title
protected

Definition at line 28 of file class.ilWebDAVMountInstructions.php.

Referenced by getWebfolderTitle().

◆ $path_to_template

ilWebDAVMountInstructions::$path_to_template
protected

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

◆ $ref_id

ilWebDAVMountInstructions::$ref_id
protected

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

◆ $request_uri

ilWebDAVMountInstructions::$request_uri
protected

Definition at line 14 of file class.ilWebDAVMountInstructions.php.

◆ $script_name

ilWebDAVMountInstructions::$script_name
protected

Definition at line 16 of file class.ilWebDAVMountInstructions.php.

◆ $settings

ilWebDAVMountInstructions::$settings
protected

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

◆ $user_agent

ilWebDAVMountInstructions::$user_agent
protected

Definition at line 13 of file class.ilWebDAVMountInstructions.php.


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