Dotclear

source: plugins/maintenance/inc/tasks/class.dc.maintenance.ziptheme.php @ 2044:4a3330bc8bd5

Revision 2044:4a3330bc8bd5, 1.5 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Revamp plugin maintenance, final setp (perhaps still some typo), addresses #1484, fixes #1208, fixes #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 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