-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
43 lines (34 loc) · 1.26 KB
/
Copy pathinstall.php
File metadata and controls
43 lines (34 loc) · 1.26 KB
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
<?php
use Redaxo\Core\Addon\Addon;
use Redaxo\Core\Exception\UserMessageException;
use Redaxo\Core\Filesystem\Dir;
use Redaxo\Core\Translation\I18n;
use Redaxo\Core\Util\Type;
$addon = Addon::require('debug');
// the filenames contain rev hashes and the old ones would never be cleaned up
Dir::delete($addon->getAssetsPath());
// extract clockwork frontend
$zipArchive = new ZipArchive();
// use path relative to __DIR__ to get correct path in update temp dir
$path = __DIR__ . '/frontend/frontend.zip';
$message = '';
try {
if (
true === $zipArchive->open($path)
&& $zipArchive->extractTo($addon->getAssetsPath('clockwork'))
) {
$zipArchive->close();
$indexPath = $addon->getAssetsPath('clockwork/index.html');
$index = Type::string(file_get_contents($indexPath));
$index = Type::string(preg_replace('/(href|src)=("?)([^>\s]+)/', '$1=$2' . $addon->getAssetsUrl('clockwork/$3'), $index));
file_put_contents($indexPath, $index);
} else {
$message = I18n::msg('debug_error_unzip') . '<br>' . $path;
}
} catch (Exception $e) {
$message = I18n::msg('debug_error_unzip') . '<br>' . $path;
$message .= '<br>' . $e->getMessage();
}
if ('' != $message) {
throw new UserMessageException($message);
}