Dotclear

Changeset 1959:2c77682177b4


Ignore:
Timestamp:
09/19/13 23:18:37 (11 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
default
Message:

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

Location:
plugins
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • plugins/importExport/inc/lib.ie.maintenance.php

    r1955 r1959  
    2424          $this->name = __('Database export'); 
    2525          $this->task = __('Download database of current blog'); 
    26           $this->step = __('Zip file ready to be downloaded.'); 
    2726 
    2827          $this->export_name = html::escapeHTML($this->core->blog->id.'-backup.txt'); 
     
    3231     public function execute() 
    3332     { 
    34           // 1) Create zip file 
    35           if (!isset($_SESSION['export_file']) || !file_exists($_SESSION['export_file'])) { 
    36                // Bad hack to skip one step 
    37                $_POST['file_name'] = date('Y-m-d-H-i-').$this->export_name; 
    38                $_POST['file_zip'] = 1; 
    39  
     33          // Create zip file 
     34          if (!empty($_POST['file_name'])) { 
    4035               // This process make an http redirect 
    4136               $ie = new maintenanceDcExportFlat($this->core); 
     
    4338               $ie->process($this->export_type); 
    4439          } 
    45           // 2) Download zip file 
     40          // Go to step and show form 
    4641          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'])) { 
    4750               // Log task execution here as we sent file and stop script 
    4851               $this->log(); 
     
    5356               $ie->process('ok'); 
    5457          } 
    55  
    56           return null; 
    57      } 
    58  
    59      public function step() 
    60      { 
    61           return isset($_SESSION['export_file']) && file_exists($_SESSION['export_file']) ? 
    62                $this->step : null; 
     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          } 
    6368     } 
    6469} 
     
    7681          $this->name = __('Database export'); 
    7782          $this->task = __('Download database of all blogs'); 
    78           $this->step = __('Zip file ready to be downloaded.'); 
    7983 
    8084          $this->export_name = 'dotclear-backup.txt'; 
     
    8488     public function execute() 
    8589     { 
    86           // 1) Create zip file 
    87           if (!isset($_SESSION['export_file']) || !file_exists($_SESSION['export_file'])) { 
    88                // Bad hack to skip one step 
    89                $_POST['file_name'] = date('Y-m-d-H-i-').$this->export_name; 
    90                $_POST['file_zip'] = 1; 
    91  
     90          // Create zip file 
     91          if (!empty($_POST['file_name'])) { 
    9292               // This process make an http redirect 
    9393               $ie = new maintenanceDcExportFlat($this->core); 
     
    9595               $ie->process($this->export_type); 
    9696          } 
    97           // 2) Download zip file 
     97          // Go to step and show form 
    9898          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'])) { 
    99107               // Log task execution here as we sent file and stop script 
    100108               $this->log(); 
     
    105113               $ie->process('ok'); 
    106114          } 
    107  
    108           return null; 
    109      } 
    110  
    111      public function step() 
    112      { 
    113           return isset($_SESSION['export_file']) && file_exists($_SESSION['export_file']) ? 
    114                $this->step : null; 
     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          } 
    115125     } 
    116126} 
  • plugins/maintenance/_services.php

    r1925 r1959  
    4646          $task->code((integer) $post['code']); 
    4747          if (($code = $task->execute()) === true) { 
     48               $maintenance->setLog($task->id()); 
    4849               $code = 0; 
    4950          } 
  • plugins/maintenance/inc/class.dc.maintenance.task.php

    r1955 r1959  
    2525     protected $code; 
    2626     protected $ts = 604800; // one week 
     27     protected $ajax = false; 
    2728 
    2829     protected $id; 
     
    139140 
    140141     /** 
     142      * Use ajax 
     143      * 
     144      * Is task use maintenance ajax script  
     145      * for steps process. 
     146      * 
     147      * @return     <b>boolean</b> Use ajax 
     148      */ 
     149     public function ajax() 
     150     { 
     151          return (boolean) $this->ajax; 
     152     } 
     153 
     154     /** 
    141155      * Get task message. 
    142156      * 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.indexcomments.php

    r1925 r1959  
    1414class dcMaintenanceIndexcomments extends dcMaintenanceTask 
    1515{ 
     16     protected $ajax = true; 
    1617     protected $group = 'index'; 
    1718     protected $limit = 500; 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.indexposts.php

    r1925 r1959  
    1414class dcMaintenanceIndexposts extends dcMaintenanceTask 
    1515{ 
     16     protected $ajax = true; 
    1617     protected $group = 'index'; 
    1718     protected $limit = 500; 
  • plugins/maintenance/index.php

    r1955 r1959  
    7070dcPage::jsPageTabs($tab); 
    7171 
    72 if (0){//$task) { 
     72if ($task && $task->ajax()) { 
    7373     echo  
    7474     '<script type="text/javascript">'."\n". 
    75      "//<![CDATA\n". 
     75     "//<![CDATA[\n". 
    7676     dcPage::jsVar('dotclear.msg.wait', __('Please wait...')). 
    7777     "//]]>\n". 
     
    8787// Success message 
    8888 
    89 if ($task && !empty($_GET['done'])) { 
    90      dcPage::success($task->success()); 
    91 } 
     89$msg = $task && !empty($_GET['done']) ? dcPage::success($task->success(),true,true,false) : ''; 
    9290 
    9391if ($task && ($res = $task->step()) !== null) { 
     
    102100          ) 
    103101     ); 
     102 
     103     echo $msg; 
    104104 
    105105     // Intermediate task (task required several steps) 
     
    135135     ); 
    136136 
     137     echo $msg; 
     138 
    137139     // Simple task (with only a button to start it) 
    138140 
  • plugins/maintenance/js/dc.maintenance.js

    r1925 r1959  
    3535                              dcMaintenanceStep(box,code); 
    3636                         } else { 
    37                               $('.step-msg',box).addClass('success'); 
     37                              $('#content h2').after($('<div/>').addClass('success').append($('.step-msg',box))); 
    3838                              $('.step-wait',box).remove(); 
    3939                              $('.step-back',box).show(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map