Dotclear

source: plugins/importExport/inc/lib.ie.maintenance.php @ 1959:2c77682177b4

Revision 1959:2c77682177b4, 3.4 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Plugin maintenance, small fixes and boss requests, addresses #999

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14class ieMaintenanceExportblog extends dcMaintenanceTask
15{
16     protected $tab = 'backup';
17     protected $group = 'zipblog';
18
19     protected $export_name;
20     protected $export_type;
21
22     protected function init()
23     {
24          $this->name = __('Database export');
25          $this->task = __('Download database of current blog');
26
27          $this->export_name = html::escapeHTML($this->core->blog->id.'-backup.txt');
28          $this->export_type = 'export_blog';
29     }
30
31     public function execute()
32     {
33          // Create zip file
34          if (!empty($_POST['file_name'])) {
35               // This process make an http redirect
36               $ie = new maintenanceDcExportFlat($this->core);
37               $ie->setURL($this->id);
38               $ie->process($this->export_type);
39          }
40          // Go to step and show form
41          else {
42               return 1;
43          }
44     }
45
46     public function step()
47     {
48          // Download zip file
49          if (isset($_SESSION['export_file']) && file_exists($_SESSION['export_file'])) {
50               // Log task execution here as we sent file and stop script
51               $this->log();
52
53               // This process send file by http and stop script
54               $ie = new maintenanceDcExportFlat($this->core);
55               $ie->setURL($this->id);
56               $ie->process('ok');
57          }
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
71class 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          }
115          else {
116               return 
117               '<p><label for="file_name">'.__('File name:').'</label>'.
118               form::field('file_name', 50, 255, date('Y-m-d-H-i-').$this->export_name).
119               '</p>'.
120               '<p><label for="file_zip" class="classic">'.
121               form::checkbox('file_zip', 1).' '.
122               __('Compress file').'</label>'.
123               '</p>';
124          }
125     }
126}
127
128class maintenanceDcExportFlat extends dcExportFlat
129{
130     /**
131      * Set redirection URL of bakcup process.
132      *
133      * Bad hack to change redirection of dcExportFlat::process()
134      *
135      * @param id   <b>string</b>  Task id
136      */
137     public function setURL($id)
138     {
139          $this->url = sprintf('plugin.php?p=maintenance&task=%s', $id);
140     }
141}
Note: See TracBrowser for help on using the repository browser.

Sites map