|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @package application |
|
4
|
|
|
* @subpackage sitemaps |
|
5
|
|
|
* @author marius orcisk <[email protected]> |
|
6
|
|
|
* @date 2010.12.05 |
|
7
|
|
|
*/ |
|
8
|
|
|
namespace vsc\application\sitemaps; |
|
9
|
|
|
|
|
10
|
|
|
use vsc\infrastructure\urls\UrlParserA; |
|
11
|
|
|
|
|
12
|
|
|
class ModuleMap extends MappingA implements ContentTypeMappingInterface, ResourceMapInterface { |
|
13
|
|
|
use ModuleMapTrait; |
|
14
|
|
|
use ResourceMapTrait; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @var string |
|
18
|
|
|
*/ |
|
19
|
|
|
private $sMainTemplatePath; |
|
20
|
|
|
/** |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
private $sMainTemplate; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* verifies if $sPath is on the path |
|
27
|
|
|
* verifies if $sPath is a valid folder and it has a config/map.php file |
|
28
|
|
|
* @param string $sPath |
|
29
|
|
|
* @return bool |
|
30
|
|
|
*/ |
|
31
|
21 |
|
public static function isValidMap ($sPath) { |
|
32
|
21 |
|
return (basename($sPath) == 'map.php' && is_file($sPath)); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
20 |
|
public function __construct($sPath, $sRegex) { |
|
36
|
20 |
|
$sPath = realpath(dirname($sPath)); |
|
37
|
20 |
|
if (basename($sPath) == 'config') { |
|
38
|
20 |
|
$sPath = substr($sPath, 0, -7); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
20 |
|
$sPath .= DIRECTORY_SEPARATOR; |
|
42
|
20 |
|
parent::__construct($sPath, $sRegex); |
|
43
|
20 |
|
} |
|
44
|
|
|
|
|
45
|
18 |
|
public function setMainTemplatePath($sPath) { |
|
46
|
18 |
|
$this->sMainTemplatePath = $this->getValidPath($sPath); |
|
47
|
18 |
|
} |
|
48
|
|
|
|
|
49
|
20 |
|
public function getMainTemplatePath() { |
|
50
|
20 |
|
return $this->sMainTemplatePath; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
18 |
|
public function setMainTemplate($sPath) { |
|
54
|
18 |
|
$this->sMainTemplate = $sPath; |
|
55
|
18 |
|
} |
|
56
|
|
|
|
|
57
|
20 |
|
public function getMainTemplate() { |
|
58
|
20 |
|
return $this->sMainTemplate; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
1 |
|
public function getNamespace() { |
|
62
|
1 |
|
return ''; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
2 |
|
public function getModulePath() { |
|
69
|
2 |
|
$sModulePath = $this->getPath(); |
|
70
|
2 |
|
if (!ModuleMap::isValidMap($sModulePath) && ClassMap::isValidMap($sModulePath)) { |
|
71
|
|
|
$sModulePath = $this->getModuleMap()->getModulePath(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
2 |
|
if (!UrlParserA::hasGoodTermination($sModulePath, DIRECTORY_SEPARATOR)) { |
|
75
|
|
|
$sModulePath .= DIRECTORY_SEPARATOR; |
|
76
|
|
|
} |
|
77
|
2 |
|
return $sModulePath; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|