1
|
|
|
<?php |
2
|
|
|
/****************************************************************** |
3
|
|
|
psite.phtml Muze Ariadne |
4
|
|
|
------------------------------------------------------------------ |
5
|
|
|
Author: Muze ([email protected]) |
6
|
|
|
Date: 31 october 2002 |
7
|
|
|
|
8
|
|
|
Copyright 2002 Muze |
9
|
|
|
|
10
|
|
|
This file is part of Ariadne. |
11
|
|
|
|
12
|
|
|
Ariadne is free software; you can redistribute it and/or modify |
13
|
|
|
it under the terms of the GNU General Public License as published |
14
|
|
|
by the Free Software Foundation; either version 2 of the License, |
15
|
|
|
or (at your option) any later version. |
16
|
|
|
|
17
|
|
|
Ariadne is distributed in the hope that it will be useful, |
18
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
GNU General Public License for more details. |
21
|
|
|
|
22
|
|
|
You should have received a copy of the GNU General Public License |
23
|
|
|
along with Ariadne; if not, write to the Free Software |
24
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
25
|
|
|
02111-1307 USA |
26
|
|
|
|
27
|
|
|
------------------------------------------------------------------- |
28
|
|
|
|
29
|
|
|
Class inheritance: pobject > ppage > pdir > psection > psite |
30
|
|
|
Description: |
31
|
|
|
|
32
|
|
|
This is the class definition file of the psite class. |
33
|
|
|
|
34
|
|
|
******************************************************************/ |
35
|
|
|
|
36
|
|
|
require_once(AriadneBasePath."/objects/psection.phtml"); |
37
|
|
|
|
38
|
|
|
class psite extends psection { // psite class definition |
39
|
|
|
|
40
|
|
|
function getConfigData() { |
|
|
|
|
41
|
|
|
global $ARConfig; |
42
|
|
|
pdir::getConfigData(); |
43
|
|
|
|
44
|
|
|
$configcache=$ARConfig->cache[$this->path]; |
45
|
|
|
$hostsubwww = $host = $_SERVER["HTTP_HOST"]; |
46
|
|
|
if (substr($host, 0, 4) == 'www.') { |
47
|
|
|
$hostsubwww = substr($host, 4); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$ariadne_workspace = getenv('ARIADNE_WORKSPACE'); |
51
|
|
|
$workspace = $ariadne_workspace && workspace::enabled($this->path); |
52
|
|
|
|
53
|
|
|
if (isset($this->data->config->url_list)) { // backwards compat check; url_list has been moved to config |
54
|
|
|
$url_list = $this->data->config->url_list; |
55
|
|
|
$workspaceurl_list = $this->data->config->workspaceurl_list; |
56
|
|
|
} else { |
57
|
|
|
$url_list = $this->data->url_list; |
58
|
|
|
$workspaceurl_list = $this->data->workspaceurl_list; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if ($workspace) { |
62
|
|
|
if (($sitenls=$workspaceurl_list["host"][$hostsubwww]) |
63
|
|
|
|| (($sitenls=$workspaceurl_list["host"]["www.".$hostsubwww]))) { |
64
|
|
|
|
65
|
|
|
$url = $workspaceurl_list["nls"][$sitenls]; |
66
|
|
|
} |
67
|
|
|
if (!$url) { |
68
|
|
|
$url=$this->data->workspaceurl; |
69
|
|
|
} |
70
|
|
|
} else { |
71
|
|
|
if (($sitenls=$url_list["host"][$hostsubwww]) |
72
|
|
|
|| (($sitenls=$url_list["host"]["www.".$hostsubwww]))) { |
73
|
|
|
|
74
|
|
|
$url = $url_list["nls"][$sitenls]; |
75
|
|
|
if (is_array($url)) { |
76
|
|
|
$urls = $url; |
77
|
|
|
$url = array_shift($urls); // default |
78
|
|
|
foreach( $urls as $_url ) { |
79
|
|
|
$_hostsubwww = preg_replace('|^(.*//www\.)|', '', $_url); |
80
|
|
|
if ($_hostsubwww == $hostsubwww) { |
81
|
|
|
$url = $_url; |
82
|
|
|
break; |
83
|
|
|
} |
84
|
|
|
$_host = preg_replace('|^(.*//)|', '', $_url); |
85
|
|
|
if ($_host == $host) { |
86
|
|
|
$url = $_url; |
87
|
|
|
break; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
} |
93
|
|
|
if (!$url) { |
94
|
|
|
$url=$this->data->url; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
if ($url) { |
99
|
|
|
$configcache->root["path"]=$this->path; |
100
|
|
|
$configcache->root["value"]=$url; |
101
|
|
|
if (!$workspace) { |
102
|
|
|
$configcache->root["list"]=$url_list; |
103
|
|
|
} else { |
104
|
|
|
$configcache->root["list"]=$workspaceurl_list; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
if ($sitenls) { |
108
|
|
|
$configcache->root["nls"] = $sitenls; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
$configcache->site=$this->path; |
113
|
|
|
$configcache->section=$this->path; |
114
|
|
|
$ARConfig->cache[$this->path]=$configcache; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
} // end of psite class definition |
118
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: