1 | <?php |
---|
2 | /** |
---|
3 | * @brief importExport, a plugin for Dotclear 2 |
---|
4 | * |
---|
5 | * @package Dotclear |
---|
6 | * @subpackage Plugins |
---|
7 | * |
---|
8 | * @copyright Olivier Meunier & Association Dotclear |
---|
9 | * @copyright GPL-2.0-only |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('DC_RC_PATH')) {return;} |
---|
13 | |
---|
14 | class ieMaintenanceExportblog extends dcMaintenanceTask |
---|
15 | { |
---|
16 | protected $perm = 'admin'; |
---|
17 | protected $tab = 'backup'; |
---|
18 | protected $group = 'zipblog'; |
---|
19 | |
---|
20 | protected $export_name; |
---|
21 | protected $export_type; |
---|
22 | |
---|
23 | protected function init() |
---|
24 | { |
---|
25 | $this->name = __('Database export'); |
---|
26 | $this->task = __('Download database of current blog'); |
---|
27 | |
---|
28 | $this->export_name = html::escapeHTML($this->core->blog->id . '-backup.txt'); |
---|
29 | $this->export_type = 'export_blog'; |
---|
30 | } |
---|
31 | |
---|
32 | public function execute() |
---|
33 | { |
---|
34 | // Create zip file |
---|
35 | if (!empty($_POST['file_name'])) { |
---|
36 | // This process make an http redirect |
---|
37 | $ie = new maintenanceDcExportFlat($this->core); |
---|
38 | $ie->setURL($this->id); |
---|
39 | $ie->process($this->export_type); |
---|
40 | } |
---|
41 | // Go to step and show form |
---|
42 | else { |
---|
43 | return 1; |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | public function step() |
---|
48 | { |
---|
49 | // Download zip file |
---|
50 | if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) { |
---|
51 | // Log task execution here as we sent file and stop script |
---|
52 | $this->log(); |
---|
53 | |
---|
54 | // This process send file by http and stop script |
---|
55 | $ie = new maintenanceDcExportFlat($this->core); |
---|
56 | $ie->setURL($this->id); |
---|
57 | $ie->process('ok'); |
---|
58 | } else { |
---|
59 | return |
---|
60 | '<p><label for="file_name">' . __('File name:') . '</label>' . |
---|
61 | form::field('file_name', 50, 255, date('Y-m-d-H-i-') . $this->export_name) . |
---|
62 | '</p>' . |
---|
63 | '<p><label for="file_zip" class="classic">' . |
---|
64 | form::checkbox('file_zip', 1) . ' ' . |
---|
65 | __('Compress file') . '</label>' . |
---|
66 | '</p>'; |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | class ieMaintenanceExportfull extends dcMaintenanceTask |
---|
72 | { |
---|
73 | protected $tab = 'backup'; |
---|
74 | protected $group = 'zipfull'; |
---|
75 | |
---|
76 | protected $export_name; |
---|
77 | protected $export_type; |
---|
78 | |
---|
79 | protected function init() |
---|
80 | { |
---|
81 | $this->name = __('Database export'); |
---|
82 | $this->task = __('Download database of all blogs'); |
---|
83 | |
---|
84 | $this->export_name = 'dotclear-backup.txt'; |
---|
85 | $this->export_type = 'export_all'; |
---|
86 | } |
---|
87 | |
---|
88 | public function execute() |
---|
89 | { |
---|
90 | // Create zip file |
---|
91 | if (!empty($_POST['file_name'])) { |
---|
92 | // This process make an http redirect |
---|
93 | $ie = new maintenanceDcExportFlat($this->core); |
---|
94 | $ie->setURL($this->id); |
---|
95 | $ie->process($this->export_type); |
---|
96 | } |
---|
97 | // Go to step and show form |
---|
98 | else { |
---|
99 | return 1; |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | public function step() |
---|
104 | { |
---|
105 | // Download zip file |
---|
106 | if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) { |
---|
107 | // Log task execution here as we sent file and stop script |
---|
108 | $this->log(); |
---|
109 | |
---|
110 | // This process send file by http and stop script |
---|
111 | $ie = new maintenanceDcExportFlat($this->core); |
---|
112 | $ie->setURL($this->id); |
---|
113 | $ie->process('ok'); |
---|
114 | } else { |
---|
115 | return |
---|
116 | '<p><label for="file_name">' . __('File name:') . '</label>' . |
---|
117 | form::field('file_name', 50, 255, date('Y-m-d-H-i-') . $this->export_name) . |
---|
118 | '</p>' . |
---|
119 | '<p><label for="file_zip" class="classic">' . |
---|
120 | form::checkbox('file_zip', 1) . ' ' . |
---|
121 | __('Compress file') . '</label>' . |
---|
122 | '</p>'; |
---|
123 | } |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | class maintenanceDcExportFlat extends dcExportFlat |
---|
128 | { |
---|
129 | /** |
---|
130 | * Set redirection URL of bakcup process. |
---|
131 | * |
---|
132 | * Bad hack to change redirection of dcExportFlat::process() |
---|
133 | * |
---|
134 | * @param id <b>string</b> Task id |
---|
135 | */ |
---|
136 | public function setURL($id) |
---|
137 | { |
---|
138 | $this->url = sprintf('plugin.php?p=maintenance&task=%s', $id); |
---|
139 | } |
---|
140 | } |
---|