30 public function __construct($a_user_agent =
'', $a_request_uri =
'', $a_http_host =
'', $a_script_name =
'', $a_client_id =
'')
35 $this->lng = $DIC->language();
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';
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];
50 if ($this->ref_id == 0) {
51 throw new Exception(
'Bad Request: No ref id given!');
57 $this->base_uri = $this->http_host . $this->script_name .
'/' . $this->client_id .
'/ref_' . $this->ref_id .
'/';
59 $this->protocol_prefixes = array(
60 'default' =>
'https://',
61 'konqueror' =>
'webdavs://',
62 'nautilus' =>
'davs://' 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';
84 $this->clientOSFlavor =
'nichtxp';
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 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';
105 return is_file($this->path_to_template);
110 return fread(
fopen($this->path_to_template,
"rb"), filesize($this->path_to_template));
115 return $this->
settings->get(
'custom_webfolder_instructions');
120 return $this->lng->txt(
'webfolder_instructions_text');
130 return $this->protocol_prefixes[
'default'] . $this->base_uri;
136 return $this->protocol_prefixes[
'default'] . $this->base_uri;
141 return $this->protocol_prefixes[
'konqueror'] . $this->base_uri;
146 return $this->protocol_prefixes[
'nautilus'] . $this->base_uri;
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);
178 if (strpos($this->user_agent,
'MSIE') !==
false) {
179 $a_instruction_tpl = preg_replace(
'/\[IF_IEXPLORE\](?:(.*))\[\/IF_IEXPLORE\]/s',
'\1', $a_instruction_tpl);
181 $a_instruction_tpl = preg_replace(
'/\[IF_NOTIEXPLORE\](?:(.*))\[\/IF_NOTIEXPLORE\]/s',
'\1', $a_instruction_tpl);
184 switch ($this->clientOS) {
186 $operatingSystem =
'WINDOWS';
189 switch ($this->clientOSFlavor) {
191 $operatingSystem =
'MAC';
194 $operatingSystem =
'LINUX';
197 $operatingSystem =
'LINUX';
202 $operatingSystem =
'UNKNOWN';
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);
209 $a_instruction_tpl = preg_replace(
'/\[IF_([A-Z_]+)\](?:(.*))\[\/IF_\1\]/s',
'\2', $a_instruction_tpl);
212 return $a_instruction_tpl;
getInstructionsFromTplFile()
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static _lookupTitle($a_id)
lookup object title
instructionsTplFileExists()
static _lookupObjectId($a_ref_id)
lookup object id
setValuesFromUserAgent($a_user_agent)
__construct($a_user_agent='', $a_request_uri='', $a_http_host='', $a_script_name='', $a_client_id='')
Class ilWebDAVMountInstructions.
setInstructionPlaceholders($a_instruction_tpl)
Gets Webfolder mount instructions for the specified webfolder.