This repository was archived by the owner on Nov 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkirby-backup-widget.html.php
48 lines (42 loc) · 1.82 KB
/
kirby-backup-widget.html.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
<?php
include __DIR__ . DS . 'kirby-backup-widget.helpers.php';
$archives = site()->find(c::get('widget.backup.destination', 'backups'))->archives()->flip();
if (get('action') == 'archive') {
$filename = date(c::get('widget.backup.date_format', 'Y-m-d')) . '.zip';
$collection = ($include = c::get('widget.backup.include', false))
? site()->find($include)
: site()->children()->not(c::get('widget.backup.destination', 'backups'), c::get('widget.backup.exclude', ''));
$result = archive($collection, $filename);
if ($result) {
notify($filename . ' created');
}
} else if (get('action') == 'delete') {
$file = $archives->find(get('archive'));
if ($file && $file->exists()) {
$file->delete();
alert($file->filename() . ' deleted');
}
}
?>
<?php if ($archives->count()) : ?>
<div class="dashboard-box">
<ul class="dashboard-items">
<?php foreach ($archives as $archive) : ?>
<li class="dashboard-item">
<figure>
<a title="download <?php echo $archive->filename() ?>" href="<?php echo $archive->url() ?>">
<span class="dashboard-item-icon dashboard-item-icon-with-border"><i class="fa fa-download ?>"></i></span>
</a>
<a title="delete <?php echo $archive->filename() ?>" href="?action=delete&archive=<?php echo $archive->filename() ?>">
<span class="dashboard-item-icon dashboard-item-icon-with-border"><i class="fa fa-trash ?>"></i></span>
</a>
<figcaption class="dashboard-item-text"><?php echo $archive->filename() ?> (<?php echo $archive->niceSize() ?>)</figcaption>
</figure>
</li>
<?php endforeach ?>
</ul>
</div>
<?php else : ?>
No backup created yet.
<a href="?action=archive"><b>Backup now</b></a>.
<?php endif ?>