Dotclear

source: plugins/maintenance/inc/tasks/class.dc.maintenance.ziptheme.php @ 3731:3770620079d4

Revision 3731:3770620079d4, 1.5 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Simplify licence block at the beginning of each file

Line 
1<?php
2/**
3 * @brief maintenance, 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
12if (!defined('DC_RC_PATH')) {return;}
13
14class dcMaintenanceZiptheme extends dcMaintenanceTask
15{
16    protected $perm  = 'admin';
17    protected $blog  = true;
18    protected $tab   = 'backup';
19    protected $group = 'zipblog';
20
21    protected function init()
22    {
23        $this->task = __('Download active theme of current blog');
24
25        $this->description = __('It may be useful to backup the active theme before any change or update. This compress theme folder into a single zip file.');
26    }
27
28    public function execute()
29    {
30        // Get theme path
31        $path  = $this->core->blog->themes_path;
32        $theme = $this->core->blog->settings->system->theme;
33        $dir   = path::real($path . '/' . $theme);
34        if (empty($path) || empty($theme) || !is_dir($dir)) {
35            return false;
36        }
37
38        // Create zip
39        @set_time_limit(300);
40        $fp  = fopen('php://output', 'wb');
41        $zip = new fileZip($fp);
42        $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#');
43        $zip->addDirectory($dir . '/', '', true);
44
45        // Log task execution here as we sent file and stop script
46        $this->log();
47
48        // Send zip
49        header('Content-Disposition: attachment;filename=theme-' . $theme . '.zip');
50        header('Content-Type: application/x-zip');
51        $zip->write();
52        unset($zip);
53        exit(1);
54    }
55}
Note: See TracBrowser for help on using the repository browser.

Sites map