|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace mQueue\View\Helper; |
|
4
|
|
|
|
|
5
|
|
|
use Zend_View_Helper_HeadScript; |
|
6
|
|
|
|
|
7
|
|
|
class HeadScript extends Zend_View_Helper_HeadScript |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Include a directory recursively |
|
11
|
|
|
* |
|
12
|
|
|
* @param string $directory |
|
13
|
|
|
* @param string $method |
|
14
|
|
|
* @param array $args |
|
15
|
|
|
*/ |
|
16
|
|
|
private function includeDirectory($directory, $method, array $args): void |
|
17
|
|
|
{ |
|
18
|
|
|
$prefix = APPLICATION_PATH . '/../'; |
|
19
|
|
|
foreach (array_reverse(glob($prefix . $directory . '/*')) as $file) { |
|
20
|
|
|
if (is_dir($file)) { |
|
21
|
|
|
$this->includeDirectory($file, $method, $args); |
|
22
|
|
|
} else { |
|
23
|
|
|
$args[0] = $this->view->cacheStamp(str_replace($prefix . 'public/', '', $file)); |
|
24
|
|
|
parent::__call($method, $args); |
|
25
|
|
|
} |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Override parent to support timestamp, compilation and concatenation. |
|
31
|
|
|
* Compiled and concatenated files must pre-exist (compiled by external tools). |
|
32
|
|
|
* |
|
33
|
|
|
* @param string $method |
|
34
|
|
|
* @param array $args |
|
35
|
|
|
* |
|
36
|
|
|
* @return self |
|
37
|
|
|
*/ |
|
38
|
12 |
|
public function __call($method, $args) |
|
39
|
|
|
{ |
|
40
|
12 |
|
if (mb_strpos($method, 'File')) { |
|
41
|
12 |
|
$fileName = $args[0]; |
|
42
|
|
|
|
|
43
|
|
|
// If file will be concatenated, use concatenation system instead |
|
44
|
12 |
|
if (is_array($fileName)) { |
|
45
|
|
|
// If we are in development, actually don't concatenate anything |
|
46
|
12 |
|
if (APPLICATION_ENV == 'development') { |
|
47
|
|
|
foreach ($fileName[1] as $f) { |
|
48
|
|
|
$this->includeDirectory('public' . $f, $method, $args); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $this; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
// Otherwise use pre-existing concatenated file |
|
55
|
12 |
|
$fileName = $fileName[0]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
12 |
|
$args[0] = $this->view->cacheStamp($fileName); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
12 |
|
return parent::__call($method, $args); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|