-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHead.php
102 lines (86 loc) · 2.28 KB
/
Head.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
class RM_Head
extends
Zend_Controller_Plugin_Abstract {
/**
* @var RM_Head
*/
private static $_self;
/**
* @var array
*/
protected static $_links = array();
/**
* @var RM_Head_JS
*/
private $_js;
/**
* @var RM_Head_CSS
*/
private $_css;
/**
* @return RM_Head
*/
public static function getInstance() {
return self::$_self;
}
public static function getModuleName() {
if (isset(static::$_links[Layouts::$moduleName])) {
return static::$_links[Layouts::$moduleName];
}
return Layouts::$moduleName;
}
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request = null) {
$this->_init();
$this->_load();
self::$_self = $this;
}
public function _init() {
$cfg = new Zend_Config_Ini( APPLICATION_PATH . '/configs/views/' . static::getModuleName() . '.ini' );
$this->_initJsCompressor($cfg);
$this->_initCssCompressor($cfg);
}
public function _load() {
try {
$this->getCSS()->add('base');
} catch (Exception $e) {
}
try {
$this->getJS()->add('base');
} catch (Exception $e) {
}
}
public function getJS() {
return $this->_js;
}
public function getCSS() {
return $this->_css;
}
public function getView() {
return Zend_Layout::getMvcInstance()->getView();
}
/**
* @param $cfg
*/
private function _initJsCompressor($cfg) {
$dependencies = RM_Dependencies::getInstance();
if (isset($dependencies->jsCompressorClass)) {
$jsCompressorClass = $dependencies->jsCompressorClass;
} else {
$jsCompressorClass = 'RM_Head_JS';
}
$this->_js = new $jsCompressorClass($cfg->js);
}
/**
* @param $cfg
*/
private function _initCssCompressor($cfg) {
$dependencies = RM_Dependencies::getInstance();
if (isset($dependencies->cssCompressorClass)) {
$cssCompressorClass = $dependencies->cssCompressorClass;
} else {
$cssCompressorClass = 'RM_Head_CSS';
}
$this->_css = new $cssCompressorClass($cfg->css);
}
}