Dotclear


Ignore:
Timestamp:
09/23/13 20:34:42 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
default
Message:

Revamp plugin maintenance, final setp (perhaps still some typo), addresses #1484, fixes #1208, fixes #999

Location:
plugins/maintenance/inc
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • plugins/maintenance/inc/class.dc.maintenance.php

    r1989 r2044  
    2626{ 
    2727     public $core; 
     28     public $p_url = 'plugin.php?p=maintenance'; 
     29 
    2830     private $tasks = array(); 
    2931     private $tabs = array(); 
     
    3436      * Constructor. 
    3537      * 
    36       * Here you register tasks and groups for tasks. 
    37       * 
    3838      * @param core <b>dcCore</b>  dcCore instance 
    3939      */ 
     
    4141     { 
    4242          $this->core = $core; 
    43  
    44           $tasks = new ArrayObject(); 
    45           $tabs = new ArrayObject(); 
    46           $groups = new ArrayObject(); 
    4743          $logs = $this->getLogs(); 
    48  
    49           # --BEHAVIOR-- dcMaintenanceRegister 
    50           $core->callBehavior('dcMaintenanceRegister', $core, $tasks, $groups, $tabs); 
    51  
    52           $this->init($tasks, $groups, $tabs); 
    53      } 
    54  
    55      /** 
    56       * Initialize list of groups and tasks. 
    57       * 
    58       * @param tasks     <b>arrayObject</b>  Array of task to register 
    59       * @param groups    <b>arrayObject</b>  Array of groups to add 
    60       * @param tabs <b>arrayObject</b>  Array of tabs to add 
    61       */ 
    62      public function init($tasks, $groups, $tabs) 
    63      { 
    64           $this->tasks = $this->groups = array(); 
    65  
    66           foreach($tasks as $task) 
    67           { 
    68                if (!class_exists($task)) { 
    69                     continue; 
    70                } 
    71  
    72                $r = new ReflectionClass($task); 
    73                $p = $r->getParentClass(); 
    74  
    75                if (!$p || $p->name != 'dcMaintenanceTask') { 
    76                     continue; 
    77                } 
    78  
    79                if (($t = new $task($this, 'plugin.php?p=maintenance')) === null 
    80                || $t->perm() === null && !$this->core->auth->isSuperAdmin() 
    81                || !$this->core->auth->check($t->perm(), $this->core->blog->id)) { 
    82                     continue; 
    83                } 
    84  
    85                $this->tasks[$task] = $t; 
    86           } 
    87  
    88           foreach($groups as $id => $name) 
    89           { 
    90                $this->groups[(string) $id] = (string) $name; 
    91           } 
    92  
    93           foreach($tabs as $id => $name) 
    94           { 
    95                $this->tabs[(string) $id] = (string) $name; 
    96           } 
    97      } 
    98  
    99      /** 
    100       * Get a tab name. 
     44          $this->init(); 
     45     } 
     46 
     47     /** 
     48      * Initialize list of tabs and groups and tasks. 
     49      * 
     50      * To register a tab or group or task,  
     51      * use behavior dcMaintenanceInit then a method of 
     52      * dcMaintenance like addTab('myTab', ...). 
     53      */ 
     54     protected function init() 
     55     { 
     56          # --BEHAVIOR-- dcMaintenanceInit 
     57          $this->core->callBehavior('dcMaintenanceInit', $this); 
     58     } 
     59 
     60     /// @name Tab methods 
     61     //@{ 
     62     /** 
     63      * Add a tab. 
     64      * 
     65      * @param id        <b>string<b> Tab ID 
     66      * @param name <b>string<b> Tab name 
     67      * @param options   <b>string<b> Options 
     68      * @return <b>dcMaintenance</b>    Self 
     69      */ 
     70     public function addTab($id, $name, $options=array()) 
     71     { 
     72          $this->tabs[$id] = new dcMaintenanceDescriptor($id, $name, $options); 
     73 
     74          return $this; 
     75     } 
     76 
     77     /** 
     78      * Get a tab. 
    10179      * 
    10280      * @param id   <b>string</b> Tab ID 
    103       * @return     <b>mixed</b> tab name or null if not exists 
     81      * @return     <b>object</b> dcMaintenanceDescriptor of a tab 
    10482      */ 
    10583     public function getTab($id) 
     
    11795          return $this->tabs; 
    11896     } 
    119  
    120      /** 
    121       * Get a group name. 
     97     //@} 
     98 
     99 
     100     /// @name Group methods 
     101     //@{ 
     102     /** 
     103      * Add a group. 
     104      * 
     105      * @param id        <b>string<b> Group ID 
     106      * @param name <b>string<b> Group name 
     107      * @param options   <b>string<b> Options 
     108      * @return <b>dcMaintenance</b>    Self 
     109      */ 
     110     public function addGroup($id, $name, $options=array()) 
     111     { 
     112          $this->groups[$id] = new dcMaintenanceDescriptor($id, $name, $options); 
     113 
     114          return $this; 
     115     } 
     116 
     117     /** 
     118      * Get a group. 
    122119      * 
    123120      * @param id   <b>string</b> Group ID 
    124       * @return     <b>mixed</b> Group name or null if not exists 
     121      * @return     <b>object</b> dcMaintenanceDescriptor of a group 
    125122      */ 
    126123     public function getGroup($id) 
     
    132129      * Get groups. 
    133130      * 
    134       * @return     <b>array</b> Array of groups ID and name 
     131      * @return     <b>array</b> Array of groups ID and descriptor 
    135132      */ 
    136133     public function getGroups() 
    137134     { 
    138135          return $this->groups; 
     136     } 
     137     //@} 
     138 
     139 
     140     /// @name Task methods 
     141     //@{ 
     142     /** 
     143      * Add a task. 
     144      * 
     145      * @param task <b>mixed<b> Class name or object 
     146      * @return     <b>boolean</b> True if it is added 
     147      * @return <b>dcMaintenance</b>    Self 
     148      */ 
     149     public function addTask($task) 
     150     { 
     151          if (class_exists($task) && is_subclass_of($task, 'dcMaintenanceTask')) { 
     152               $this->tasks[$task] = new $task($this); 
     153          } 
     154 
     155          return $this; 
    139156     } 
    140157 
     
    174191          return $res; 
    175192     } 
    176  
     193     //@} 
     194 
     195 
     196     /// @name Log methods 
     197     //@{ 
    177198     /** 
    178199      * Set log for a task. 
     
    268289          return $this->logs; 
    269290     } 
     291     //@} 
    270292} 
  • plugins/maintenance/inc/class.dc.maintenance.task.php

    r1989 r2044  
    3333     protected $id; 
    3434     protected $name; 
     35     protected $description; 
    3536     protected $tab = 'maintenance'; 
    3637     protected $group = 'other'; 
     
    5051      * @param p_url     <b>string</b>  Maintenance plugin url 
    5152      */ 
    52      public function __construct($maintenance, $p_url) 
     53     public function __construct($maintenance) 
    5354     { 
    5455          $this->maintenance = $maintenance; 
     
    6162          } 
    6263 
    63           $this->p_url = $p_url; 
     64          $this->p_url = $maintenance->p_url; 
    6465          $this->id = get_class($this); 
    6566 
     
    191192 
    192193     /** 
     194      * Get task description. 
     195      * 
     196      * @return     <b>string</b>  Description 
     197      */ 
     198     public function description() 
     199     { 
     200          return $this->description; 
     201     } 
     202 
     203     /** 
    193204      * Get task tab. 
    194205      * 
     
    322333          $this->maintenance->setLog($this->id); 
    323334     } 
     335 
     336     public function help() 
     337     { 
     338          return null; 
     339     } 
    324340} 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.cache.php

    r1925 r2044  
    2121          $this->success           = __('Templates cache directory emptied.'); 
    2222          $this->error        = __('Failed to empty templates cache directory.'); 
     23 
     24          $this->description = __("It may be useful to empty this cache when modifying a theme's .html or .css files (or when updating a theme or plugin). Notice : with some hosters, the templates cache cannot be emptied with this plugin. You may then have to delete the directory <strong>/cbtpl/</strong> directly on the server with your FTP software."); 
    2325     } 
    2426 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.countcomments.php

    r1984 r2044  
    2121          $this->success           = __('Comments and trackback counted.'); 
    2222          $this->error        = __('Failed to count comments and trackbacks.'); 
     23 
     24          $this->description = __('Count again comments and trackbacks allows to check their exact numbers. This operation can be useful when importing from another blog platform (or when migrating from dotclear 1 to dotclear 2).'); 
    2325     } 
    2426 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.indexcomments.php

    r1989 r2044  
    2727          $this->success           = __('Comments index done.'); 
    2828          $this->error        = __('Failed to index comments.'); 
     29 
     30          $this->description = __('Index all comments and trackbacks in search engine index. This operation is necessary, after importing content in your blog, to use internal search engine, on public and private pages.'); 
    2931     } 
    3032 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.indexposts.php

    r1989 r2044  
    2727          $this->success           = __('Entries index done.'); 
    2828          $this->error        = __('Failed to index entries.'); 
     29 
     30          $this->description = __('Index all entries in search engine index. This operation is necessary, after importing content in your blog, to use internal search engine, on public and private pages.'); 
    2931     } 
    3032 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.logs.php

    r1925 r2044  
    2121          $this->success           = __('Logs deleted.'); 
    2222          $this->error        = __('Failed to delete logs.'); 
     23 
     24          $this->description = __('Logs record all activity and connection to your blog history. Unless you need to keep this history, consider deleting these logs from time to time.'); 
    2325     } 
    2426 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.vacuum.php

    r1984 r2044  
    1818     protected function init() 
    1919     { 
     20          $this->name              = __('Optimise database'); 
    2021          $this->task         = __('optimize tables'); 
    2122          $this->success           = __('Optimization successful.'); 
    2223          $this->error        = __('Failed to optimize tables.'); 
     24 
     25          $this->description = __("After numerous delete or update operations on Dotclear's database, it gets fragmented. Optimizing will allow to defragment it. It has no incidence on your data's integrity. It is recommended to optimize before any blog export."); 
    2326     } 
    2427 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.zipmedia.php

    r1989 r2044  
    2222     { 
    2323          $this->task = __('Download media folder of current blog'); 
     24 
     25          $this->description = __('It may be useful to backup your media folder. This compress all content of media folder into a single zip file. Notice : with some hosters, the media folder cannot be compressed with this plugin if it is too big.'); 
    2426     } 
    2527 
  • plugins/maintenance/inc/tasks/class.dc.maintenance.ziptheme.php

    r1989 r2044  
    2222     { 
    2323          $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.'); 
    2426     } 
    2527 
Note: See TracChangeset for help on using the changeset viewer.

Sites map